package com.ljc.api;

import com.ljc.entity.FollowingGroup;
import com.ljc.interfaces.FollowingGroupApi;
import com.ljc.mapper.FollowingGroupMapper;
import org.apache.dubbo.config.annotation.DubboService;

import javax.annotation.Resource;
import java.util.List;

@DubboService
public class FollowingGroupApiImpl implements FollowingGroupApi {
    @Resource
    private FollowingGroupMapper followingGroupMapper;

    /**
     * 通过类型获得分组
     */
    @Override
    public FollowingGroup getByType(String type) {
        return followingGroupMapper.getByType(type);
    }

    /**
     * 通过id获得分组
     */
    @Override
    public FollowingGroup getById(Long id) {
        return followingGroupMapper.getById(id);
    }

    /**
     * 查询当前用户的所有关注分组
     */
    @Override
    public List<FollowingGroup> getByUserId(Long userId) {
        return followingGroupMapper.getByUserId(userId);
    }

    /**
     * 新建用户关注分组
     */
    @Override
    public FollowingGroup addFollowingGroup(FollowingGroup followingGroup) {
        followingGroupMapper.addFollowingGroup(followingGroup);
        return followingGroup;
    }

    /**
     * 获取用户关注分组
     */
    @Override
    public List<FollowingGroup> getUserFollowingGroups(Long userId) {
        return followingGroupMapper.getUserFollowingGroups(userId);
    }
}
